﻿@using Easy.CMS.Section.Models
@model SectionWidget
@{
    Layout = null;
}

@foreach (SectionGroup group in Model.Groups.OrderBy(m => m.Order))
{
    Html.RenderPartial("SectionGroup.Edit", group);
}
<script type="text/javascript">
    $("#section-groups").sortable({
        handle: ".panel-heading",
        stop: function (event, ui) {
            var result = {}
            $(event.target).find(".section-group").each(function (i) {
                result["[" + i + "].ID"] = $(this).data("id");
                result["[" + i + "].Order"] = i + 1;
            });
            $.post("@Url.Action("Sort","SectionGroup")", result, function (data) { reload(); }, "json");
        }
    });
    $(".section-group .list-group").sortable({
        stop: function (event, ui) {
            var result = {}
            $(event.target).find(".list-group-item").each(function (i) {
                result["[" + i + "].ID"] = $(this).data("id");
                result["[" + i + "].Order"] = i + 1;
            });
            $.post("@Url.Action("SortContent","SectionGroup")", result, function (data) { reload(); }, "json");
        }
    });
</script>